package com.kqb.controller;

import com.kqb.common.controller.base.BaseController;
import com.kqb.common.domain.AjaxResult;
import com.kqb.pojo.dto.EmployeeDto;
import com.kqb.pojo.dto.EmployeeQueryDto;
import com.kqb.service.IEmployeeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author 杉果树皮
 * @date 2025/2/17 20:14
 * @description:
 */
@RestController
@RequestMapping("/api")
@Api(tags = "员工")
public class EmployeeController extends BaseController {
    @Autowired
    private IEmployeeService iEmployeeService;

    @PostMapping("/employee")
    @ApiOperation("添加员工")
    public AjaxResult save(@RequestBody EmployeeDto employeeDTO) {
        return iEmployeeService.save(employeeDTO);
    }

    @DeleteMapping("/employee/{id}")
    @ApiOperation("刪除员工")
    public AjaxResult delete(@PathVariable("id") Integer id) {
        return iEmployeeService.deleteById(id);
    }

    @GetMapping("/employee")
    @ApiOperation("查看所有员工")
    public AjaxResult selectByPage(EmployeeQueryDto employeeQueryDTO) {
        return iEmployeeService.selectByPage(employeeQueryDTO);
    }

    @GetMapping("/employee/{type}")
    @ApiOperation("查看所有员工根据员工类型")
    public AjaxResult selectByType(@PathVariable("type") String type) {
        return iEmployeeService.selectByType(type);
    }
}
